"""
1.定义一个类重写__iter__和__next__
2.__next__：列表数据   拿到最小值min()返回 并且把拿到的值删除  条件 列表产长度为空 抛出异常
3.实例化对象，遍历获取值
"""
li = [23,67,33,90,12,21,9]
# 9 12 21 23 33
# 90 67 33
class MySort():
    def __init__(self,li):
        self.li = li

    def __iter__(self):
        return self

    def __next__(self):
        if len(self.li) == 0:
            raise StopIteration
        self.minNum = min(self.li)  # 获取最小值
        # 根据值进行删除 pop clear del remove
        self.li.remove(self.minNum)
        return self.minNum

ms = MySort(li)
for i in ms:
    print(i,end=" ")